/**
 * 
 */
package com.coder520.sync_learning.demo;

import java.util.concurrent.TimeUnit;

/**
 * @author zhaoyibo
 *
 */
public class ThreadGroupEnumerateThreadGroups {
	public static void main(String[] args) throws InterruptedException {
		
		
		//mygroup1的父group是main,mygroup2的父group是mygroup1
		//如果进行递归，复制的结果是2，如果不递归，结果是1
		ThreadGroup myGroup1=new ThreadGroup("MyGroup1");
		ThreadGroup myGroup2=new ThreadGroup(myGroup1, "Mythread2");
		
		TimeUnit.MILLISECONDS.sleep(1);
		
		ThreadGroup mainGroup=Thread.currentThread().getThreadGroup();
		
		ThreadGroup[] list=new ThreadGroup[mainGroup.activeGroupCount()];
		
		mainGroup.list();
		int recurseSize=mainGroup.enumerate(list);
		System.out.println(recurseSize);
		
		recurseSize=mainGroup.enumerate(list, false);
		System.out.println(recurseSize);
	}
}
